package com.ywk.pattern._18_memento;

public class GameRole {
    private int vit;
    private int atk;
    private int def;

    public int getVit() {
        return vit;
    }

    public void setVit(int vit) {
        this.vit = vit;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    //初始化状态
    public void GetInitState() {
        this.vit = 100;
        this.atk = 100;
        this.def = 100;
    }

    //战斗后
    public void Fight() {
        this.vit = 0;
        this.atk = 0;
        this.def = 0;
    }


    public void StateDisplay() {
        System.out.println("GameRole{" +
                "vit=" + vit +
                ", atk=" + atk +
                ", def=" + def +
                '}');
    }

    //保存游戏状态
    public RoleStateMemento SaveState() {
        return new RoleStateMemento(vit, atk, def);
    }

    //恢复游戏状态
    public void RecoveryState(RoleStateMemento menmento) {
        this.vit = menmento.getVit();
        this.atk = menmento.getAtk();
        this.def = menmento.getDef();
    }
}
